status, err: OSStatus; (* We'll use this to test the outcome of each MP function. *)
terminationQueue: MPQueueID; (* This queue will report the completion of the task. *)
communicationQueue: MPQueueID; (* This queue will be used to communicate between the app and the task. *)
task: MPTaskID; (* This will be the ID of the task we create. *)
myString: Str255;
itemHit: Integer;
tempStr: Str255;
begin
if (not MPLibraryIsLoaded) then
begin
ParamText('Can''t run without the ', MPLibraryPName, ' shared library.', '');
itemHit := Alert(129, nil);
exit(Test);
end;
status := MPCreateQueue(terminationQueue); (* Create the queue which will report the completion of the task. *)
if (status <> noErr) then
begin
tempStr := 'Cannot create the termination queue:\n';
Test := failure(tempStr, 'MPCreateQueue', status);
exit(Test);
end;
status := MPCreateQueue(communicationQueue); (* Create the queue we'll use to communicate with. *)
if (status <> noErr) then
begin
err := MPDeleteQueue(terminationQueue);
tempStr := 'Cannot create the communication queue:\n ';
Test := failure(tempStr, 'MPCreateQueue', status);
exit(Test);
end;
status := MPCreateTask(HelloWorld, communicationQueue, kMPUseDefaultStackSize, terminationQueue, nil, nil, kMPNormalTaskOptions, task); (* This is the task function. *)
(* This is the parameter to the task function. *)
(* We'll use whatever the MP system software gives us. *)
(* We'll use this to sense task completion. *)
(* We won't use the first part of the termination message. *)
(* We won't use the second part of the termination message. *)
(* Use the normal task options. (Currently this *must* be zero!) *)
(* Here's where the ID of the new task will go. *)
if (status <> noErr) then
begin
err := MPDeleteQueue(terminationQueue);
err := MPDeleteQueue(communicationQueue);
tempStr := '';
Test := failure(tempStr, 'MPCreateTask', status);
exit(Test);
end;
receiveString(communicationQueue, myString);
ParamText(myString, 'brought to you by Matthew Xavier Mora mxmora@apple.com', 'Developer Technical Support,', 'MW Pascal and MP.p interfaces');
itemHit := Alert(128, nil);
{ Wait for the task to complete: }
status := MPWaitOnQueue(terminationQueue, nil, nil, nil, kDurationForever);
if (status <> noErr) then
begin
tempStr := 'While waiting for task completion:\n ';
err := failure(tempStr, 'MPWaitOnQueue', status);
end;
status := MPDeleteQueue(terminationQueue);
if (status <> noErr) then
begin
tempStr := 'Can''t delete the termination queue:';
err := failure(tempStr, 'MPDeleteQueue', status);
end;
status := MPDeleteQueue(communicationQueue);
if (status <> noErr) then
begin
tempStr := 'Can''t delete the communication queue: ';